//
//  BottomTotalView.m
//  KuWoCan
//
//  Created by hwd on 17/3/15.
//  Copyright © 2017年 hwd. All rights reserved.
//

#import "BottomTotalView.h"

@implementation BottomTotalView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)init
{
    if (self = [super init])
    {
        [self setUpUI];
    }
    return self;
}

- (void)setUpUI
{
    [self setBackgroundColor:[UIColor whiteColor]];

    UIImageView *imgView = [UIImageView new];
    imgView.image = kImg(@"gouwuche");
    [self addSubview:imgView];
    [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@15);
        make.top.equalTo(@-15);
        make.size.mas_equalTo(CGSizeMake(60, 60));
    }];
    
    UILabel *oTotalConstLab = [UILabel new];
    oTotalConstLab.textColor = [UIColor blackColor];
    oTotalConstLab.font = [UIFont systemFontOfSize:17.0];
    oTotalConstLab.textAlignment = NSTextAlignmentLeft;
    oTotalConstLab.text = @"合计:";
    [self addSubview:oTotalConstLab];
    [oTotalConstLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(imgView.mas_right).offset(15);
        make.height.equalTo(@17);
        make.top.equalTo(@10);
    }];

    
    //parameter:合记
    _oTotalParaLab = [UILabel new];
    _oTotalParaLab.textColor = [UIColor redColor];
    _oTotalParaLab.font = [UIFont systemFontOfSize:17.0];
    _oTotalParaLab.textAlignment = NSTextAlignmentLeft;
    _oTotalParaLab.text = @"￥0.0";
    [self addSubview:_oTotalParaLab];
    [_oTotalParaLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(oTotalConstLab.mas_right).offset(5);
        make.height.equalTo(@17);
        make.top.equalTo(oTotalConstLab.mas_top);
    }];
    
    
    //parameter:共多少见
    _oNumberLab = [UILabel new];
    _oNumberLab.textColor = [UIColor grayColor];
    _oNumberLab.font = [UIFont systemFontOfSize:14.0];
    _oNumberLab.textAlignment = NSTextAlignmentLeft;
    _oNumberLab.text = @"共0件商品";
    [self addSubview:_oNumberLab];
    [_oNumberLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(oTotalConstLab.mas_left);
        make.height.equalTo(@14);
        make.top.equalTo(oTotalConstLab.mas_bottom).offset(5);
    }];

    self.commitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.commitBtn.backgroundColor = KwBlueColor;
    [self.commitBtn setTitle:@"订单提交" forState:UIControlStateNormal];
    [self.commitBtn setTitleColor:[UIColor whiteColor]  forState:UIControlStateNormal];
    [self.commitBtn addTarget:self action:@selector(commitAction) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.commitBtn];
    [self.commitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.bottom.top.equalTo(@0);
        make.width.equalTo(@110);
    }];
}

- (void)commitAction
{
    if (_block)
    {
        _block();
    }
}



@end
